var express = require('express');
var router = express.Router();

/* GET home page. */
const { getMyOrders, getOrdersById, updateOrder, delOrder, cancelOrder , getAllOrders,addOrder} = require('../service/ordersService')


// 获取我负责的所有订单
router.get('/getMyOrders', async function (req, res, next) {
  res.send(await getMyOrders(req.query))
});


// 查看订单详情
router.get('/getOrdersById', async function (req, res, next) {
  res.send(await getOrdersById(req.query))
});


// 修改订单
router.post('/updateOrder', async function (req, res, next) {
  res.send(await updateOrder(req.body))
});


// 删除订单
router.post('/delOrder', async function (req, res, next) {
  res.send(await delOrder(req.body))
});

//管理员查看所有订单
router.get('/getOrders',async function(req,res,next){
  res.send(await getAllOrders(req.query))
})

// 退保申请处理
router.post('/cancelOrder', async function (req, res, next) {
  res.send(await cancelOrder(req.body))
});

router.get('/getAllOrders',async (req,res,next)=>{
  res.send(await getAllOrders(req.query))
})

// 客户下单
router.post('/addOrder',async(req,res,next)=>{
  res.send(await addOrder(req.body))
})


module.exports = router;